package main

// main
//
//	@Description: 02-工厂方法：每个产品对应一个工厂类（抽象工厂生产一类抽象产品）
func main() {
	xiaoMiFactory := XiaoMiFactory{}
	xiaoPhone := xiaoMiFactory.makePhone()
	xiaoPhone.call()

	huaWeiFactory := HuaWeiFactory{}
	huaWeiPhone := huaWeiFactory.makePhone()
	huaWeiPhone.call()

}

// AbstractFactory
// @Description: 抽象工厂
type AbstractFactory interface {
	//制造抽象产品
	makePhone() Phone
}

type XiaoMiFactory struct {
}

func (XiaoMiFactory) makePhone() Phone {
	return XiaoMiPhone{}
}

type HuaWeiFactory struct {
}

func (HuaWeiFactory) makePhone() Phone {
	return HuaWeiPhone{}
}

type Phone interface {
	call()
}

type XiaoMiPhone struct {
}

type HuaWeiPhone struct {
}

func (HuaWeiPhone) call() {
	println("华为手机打电话")
}

func (XiaoMiPhone) call() {
	println("小米手机打电话")
}
